import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {
 
	public static void main(String[] args) throws Exception {
		ServerSocket serverSocket = new ServerSocket(1234);
		
		System.out.println("start. . .");
		Socket clientSocket = serverSocket.accept();
		ObjectInputStream ois = new ObjectInputStream(clientSocket.getInputStream());

		while (true) {
			try {
				//用clientSocket的输入流创建对象输入流objInput
				User user = (User)ois.readObject();
				System.out.println(user);
				//用clientSocket的输入流创建对象输入流objInput2
//		ObjectInputStream objInput2 = new ObjectInputStream(clientSocket.getInputStream());
//				user = (User)objInput.readObject();
//				System.out.println(user);
			} catch (Exception e) {
				e.printStackTrace();
				break;
			}
		}
		
		
//		clientSocket.close();
//		serverSocket.close();
	}
 
}